home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbfssf.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-06-25  |  3.2 KB  |  112 lines

  1. (*===========================================================================*)
  2. (* File subsystem -- Send a file                                             *)
  3. (*                                                                           *)
  4. (*   Copyright 1988, 1989, 1991 by H. Roy Engehausen.  All rights reserved.  *)
  5. (*   This software may be freely distributed and used, but it may not        *)
  6. (*   under any circumstances be sold by anyone other than the author.        *)
  7. (*   It may be distributed by a commercial company as long as it is          *)
  8. (*   for no cost.                                                            *)
  9. (*                                                                           *)
  10. (*===========================================================================*)
  11.  
  12. {$O+}
  13.  
  14. UNIT BBFSSF;
  15.  
  16. INTERFACE
  17.  
  18.   USES
  19.     bbdummy;
  20.  
  21.   PROCEDURE send_file(file_to_send      : file_name_str;
  22.                       send_to_conv_task : BOOLEAN);
  23.  
  24.   IMPLEMENTATION
  25.  
  26.   USES
  27.     DOS,
  28.     bbconvm,
  29.     bbfu,
  30.     bbsdata,
  31.     bbsema2,
  32.     bbstr;
  33.  
  34. (*===========================================================================*)
  35. (* Send a message file to the user                                           *)
  36. (*===========================================================================*)
  37.  
  38.   PROCEDURE send_file(file_to_send      : file_name_str;
  39.                       send_to_conv_task : BOOLEAN);
  40.  
  41.   VAR
  42.     cr_str       : STRING[1];
  43.     i            : INTEGER;
  44.     text_buffer  : STRING[254];
  45.  
  46.   BEGIN;
  47.  
  48.     cr_str := cr;
  49.  
  50.     text_buffer := open_text_file(file_to_send, TRUE);
  51.  
  52.     IF text_buffer <> '' THEN
  53.       BEGIN;
  54.         send_tnc_data_str(cr + text_buffer + cr);
  55.         active_tcb^.error_sw := TRUE;
  56.         EXIT;
  57.       END;
  58.  
  59.     WITH active_tcb^.io_fe^ DO
  60.       BEGIN;
  61.  
  62.         (*-------------------------------------------------------------------*)
  63.         (* Read from file sending as we go                                   *)
  64.         (*-------------------------------------------------------------------*)
  65.  
  66.         REPEAT
  67.  
  68.           READ(fe_text, text_buffer);
  69.  
  70.           IF EOLN(fe_text) THEN
  71.             BEGIN;
  72.               READLN(fe_text);
  73.  
  74.               send_tnc_data_str(text_buffer + cr);
  75.  
  76.               IF send_to_conv_task THEN
  77.                 BEGIN;
  78.                   add_c_string(active_tcb^.conv_tcb, @text_buffer, 1);
  79.                   add_c_string(active_tcb^.conv_tcb, @cr_str, 1);
  80.                 END;
  81.  
  82.             END
  83.           ELSE
  84.             BEGIN;
  85.  
  86.               send_tnc_data_str(text_buffer);
  87.  
  88.               IF send_to_conv_task THEN
  89.                 add_c_string(active_tcb^.conv_tcb, @text_buffer, 1);
  90.  
  91.             END;
  92.  
  93.         UNTIL EOF(fe_text); (*----- Read loop -------------------------------*)
  94.  
  95.       END;
  96.  
  97.     (*-------------------------------------------------------------------*)
  98.     (* Close things up                                                   *)
  99.     (*-------------------------------------------------------------------*)
  100.  
  101.     text_buffer := close_text_file;
  102.  
  103.     IF text_buffer <> '' THEN
  104.       BEGIN;
  105.         send_tnc_data_str(cr + text_buffer + cr);
  106.         active_tcb^.error_sw := TRUE;
  107.       END;
  108.  
  109.   END;
  110.  
  111. END.
  112.